package com.jn.moduledemo.login;

import android.content.Intent;
import android.view.View;
import android.widget.Button;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.jn.moduledemo.common.base.BaseActivity;
import com.jn.moduledemo.common.provider.ILoginProvider;

@Route(path = "/login/LoginActivity")
public class LoginActivity extends BaseActivity implements View.OnClickListener {
    private String from;
    @Autowired(name = "from")
    String from2;

    @Autowired
    ILoginProvider mProvider;
    private Button mLoginButton;
    @Override
    public int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    public void init() {
        ARouter.getInstance().inject(this);
        Intent intent = getIntent();
        String from = intent.getStringExtra("from");
        showToast(from2);
        mLoginButton = findViewById(R.id.login_button);
        mLoginButton.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.login_button) {
            if (mProvider == null) {
                //mProvider = ARouter.getInstance().navigation(ILoginProvider.class);
                mProvider = (ILoginProvider) ARouter.getInstance().build("/login/LoginProvider").navigation();
            }
            mProvider.setLoginStatus(true);

            Intent intent = new Intent();
            intent.putExtra("tab", from2);
            setResult(RESULT_OK, intent);
            finish();
        }
    }
}